# coding: utf-8

# html 下载器
import urllib2


class HtmlDownLoader(object):
    def download(self, url):  # 下载html
        if url is None:
            return  None

        resp = urllib2.urlopen(url)  # 获取html

        if resp.getcode() != 200:  # 判断请求是否成功
            return None

        return resp.read()  # 返回html内容


        # req = urllib2.Request(url)
        # with urllib2.urlopen(req, timeout=50) as resp:
        #     if resp.code != 200:
        #         return None
        #     return resp.read()
